package com.lvcoding.duxiefenlidemo.controller;

import com.lvcoding.duxiefenlidemo.domain.Test;
import com.lvcoding.duxiefenlidemo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @description 描述
 * @date   2021-12-31 上午10:11
 * @author  wuyanshen
 */
@RequestMapping("test")
@RestController
public class TestController {

    @Autowired
    private TestService testService;


    @PostMapping("add")
    public String add() {

        Test test = new Test();
        test.setId(12);
        test.setName("test-aaaaa");
        testService.save(test);

        return "新增成功";
    }


    @GetMapping("list")
    public Map list() {
        List<Test> list = testService.list();
        Map<String, Object> map = new HashMap<>();
        map.put("list", list);
        return map;
    }
}
